package us.kg.kotoriforest.springmvc.restful.vo.response;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import us.kg.kotoriforest.springmvc.restful.pojo.Employee;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author Kotori rotroutine@163.com
 * @since 2025/2/8
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
public class EmployeeResponseVo {
    private String name;
    private String email;
    private String gender;
    private String address;
    private BigDecimal salary;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date birthday;

    public EmployeeResponseVo(Employee employee) {
        this.name = employee.getName();
        this.email = employee.getEmail();
        this.gender = employee.getGender();
        this.address = employee.getAddress();
        this.salary = employee.getSalary();
        this.birthday = employee.getBirthday();
    }

    public static EmployeeResponseVo of(Employee employee) {
        return new EmployeeResponseVo(employee);
    }

    public static List<EmployeeResponseVo> of(List<Employee> employees) {
        return employees.stream().map(EmployeeResponseVo::new).collect(Collectors.toList());
    }
}
